<div data-options="fit:true,border:false">
	<div class="con"  style="-moz-user-select:none;">
		<table id="memberupper"></table>
	</div>
</div>

<script>
	var memberupperSearch = function (level) {
		var height= 560 - 96;
		var width =  940 - 2;
		$("#memberupper").datagrid({
			width: width,
			height: height,//高度
			singleSelect: true,//如果为true，则只允许选择一行
			striped: true,//是否显示斑马线效果。
			rownumbers: false,//如果为true，则显示一个行号列。
			pagination: true,//是否显示分页
			pageSize: 10,
			pageList: [10, 15, 20, 25],
			method: 'post',
			sortName: 'upper_level',
			sortOrder: 'asc',
			idField: 'id',
			url: '/admin/member/upper',
			queryParams: {
				id: '<?php echo $id;?>',
			},
			fitColumns: false,//真正的自动展开/收缩列的大小，以适应网格的宽度，防止水平滚动。
			nowrap: true,//如果为true，则在同一行中显示数据。设置为true可以提高加载性能。 是否换行
			selectOnCheck: false,
			checkOnSelect: true,
			toolbar: '#tb<?php echo $uniqid;?>',
			columns: [[
				{field:'upper_level',title:'上级层级',align:'center', width:'10%'},
				{field:'id',title:'会员ID',width:'10%'},
				{field:'avatar',title:'头像',width:'5%',formatter:function (value,rowData,rowIndex){
						return value ? "<img height='25px' style='border-radius: 5px;' src='"+value+"'>" : '';
					}},
				{field:'nickname',title:'用户',width:'15%'},
				{field:'parent_member_id',title:'推荐人',width:'10%'},
				{field:'phone',title:'手机号',width:'15%'},
				{field:'level_info',title:'身份',width:'10%', formatter(value, rowData){
						return value ? value.name : '普通会员';
					}},
				{field:'money',title:'余额',width:'8%',sortable:true},
				{field:'score',title:'积分',width:'8%',sortable:true},
				{field:'total_income',title:'累计佣金',width:'8%',sortable:true},
				{field:'total_consume',title:'消费金额',width:'8%',sortable:true},
				{field:'child_user_count',title:'团队人数',width:'8%',formatter:function (value,rowData,rowIndex){
						return value>0 ? "<a style='cursor: pointer' href='javascript:void(0)' onclick='memberTeams(\"" + rowData.nickname + '\",' + rowData.id + ")'>" + value + "</a>" : 0;
					}},
				{field:'team_consume',title:'团队业绩',width:'8%',sortable:true},
				{field:'status',title:'状态',width:'8%',formatter:function (value,rowData,rowIndex){
						return value ? '显示' : '隐藏';
					}},
				{field:'created_at',title:'加入时间',width:'18%',sortable:true},
				{
					field: 'options', title: '操作', align:'center', width: '13%', formatter: function (value, rowData, rowIndex) {
						let buttons = '<div class="table"><span class="l-btn l-btn-small color9 table" onclick="memberEdit(\'' + rowData.id + '\')"><span class="l-btn-text">详情</span></span>';
						return buttons + '</div>';
					}
				},
			]],
			onDblClickRow: function (index, field) {
				memberteamEdit();
			}
		});
	};
	onDatagridResize("#memberupper");
	memberupperSearch(1);
</script>
